package com.luyou.a08;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author 28336
 * @version 1.0
 * Create by 2023/12/25 8:55
 */
@RestController
public class MyController {

    @Lazy
    @Autowired
    private BeanForRequest beanForRequest;

    @Lazy
    @Autowired
    private BeanForSession beanForSession;

    @Lazy
    @Autowired
    private BeanForApplication beanForApplication;


    @GetMapping(value = "/test", produces = "text/html")
    public String test(HttpServletRequest request, HttpSession session){
        //设置过期时间为10秒
        session.setMaxInactiveInterval(10);
        return "<ul>"+
                "<li>request scope: " + beanForRequest + "<li>" +
                "<li>session scope: " + beanForSession + "<li>" +
                "<li>application scope: " + beanForApplication + "<li>" +
                "</ur>";
    }
}
